<%# The license inside this block applies to this file.
	# Copyright 2020 Google Inc.
	# Licensed under the Apache License, Version 2.0 (the "License");
	# you may not use this file except in compliance with the License.
	# You may obtain a copy of the License at
	#
	#     http://www.apache.org/licenses/LICENSE-2.0
	#
	# Unless required by applicable law or agreed to in writing, software
	# distributed under the License is distributed on an "AS IS" BASIS,
	# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	# See the License for the specific language governing permissions and
	# limitations under the License.
-%>
<% unless version == 'ga' -%>
// Resource object was flattened in GA API
if nestedResource, ok := res["resource"]; ok {
	if resObj, ok := nestedResource.(map[string]interface{}); ok {
		res["resourceUri"] = resObj["uri"]
		delete(res, "resource")
	}
}

// Beta attestation.attestation.genericSignedAttestation
// => GA attestation
if attV, ok := res["attestation"]; ok && attV != nil {
	att := attV.(map[string]interface{})
	if nestedAttV, ok := att["attestation"]; ok && nestedAttV != nil {
		nestedAtt := nestedAttV.(map[string]interface{})
		if genericV, ok := nestedAtt["genericSignedAttestation"]; ok {
			genericAtt := genericV.(map[string]interface{})
			res["attestation"] = map[string]interface{}{
				"serializedPayload": genericAtt["serializedPayload"],
				"signatures":        genericAtt["signatures"],
			}
		}
	}
}

<% else -%>
// encoder logic only in non-GA version
<% end -%>
return res, nil
